﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MindFusion.Charting.Wpf;

namespace Presentation
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {

        NamesList na;
        List<double> data;

        public MainWindow()
        {
            InitializeComponent();
            na = new NamesList();
            barChart1.DataSource = na;

            data = new List<double>() { 1, 2, 3, 4, 5, 6 };

            setHorAxesSettings();
            addSingleHorSeries(BarType.Horizontal);
            barChart1.Title = "Количество имён";
        }

        private void setHorAxesSettings()
        {
            barChart1.XAxisSettings.Interval = 10;
            barChart1.XAxisSettings.Title = "Количество имён";
            barChart1.XAxisSettings.LabelType = LabelType.AutoScale;

            barChart1.YAxisSettings.LabelType = LabelType.CustomText;
            barChart1.YAxisSettings.Interval = 1;
            barChart1.YAxisSettings.Title = "Имена";
            barChart1.YLabelPath = "Name";
        }

        private void addSingleHorSeries(BarType barType)
        {
            barChart1.Series.Clear();
            BarSeries series1 = new BarSeries();
            Annotation annotation = new Annotation();
            annotation.Index = 3;
            annotation.Label = "Опачки";
            annotation.Value = 25;
            annotation.AnnotationType = AnnotationType.Stick;
            annotation.Stroke = Brushes.DarkRed;
            annotation.Size = 7;
            series1.Annotations.Add(annotation);
            series1.BarType = barType;
            series1.YData = data;
            series1.Title = "Количество имён";
            series1.XDataPath = "CountName";
            series1.Fills.Add(Brushes.Aqua);
            barChart1.Series.Add(series1);
            barChart1.UpdateChart();
        }
    }
}
